﻿#include "filecheck.h"
#include <QApplication>
#include <QFile>
#include <QFontDatabase>
#include <QDebug>
#include <QResource>
#include "iconhelper.h"
#include "appinit.h"


int main(int argc, char *argv[])
{
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
    QApplication::setAttribute(Qt::AA_Use96Dpi);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
    QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
#endif

    QApplication a(argc, argv);
    a.setFont(QFont("Microsoft Yahei", 9));
    a.setWindowIcon(QIcon(":/res/icon.png"));

    AppInit::Instance()->start();
    IconHelper::Load();

    //加载样式表
    QFile file(":/res/style.css");
    if (file.open(QFile::ReadOnly))
    {
        QString qss = QLatin1String(file.readAll());
        QString paletteColor = qss.mid(20, 7);
        qApp->setPalette(QPalette(QColor(paletteColor)));
        qApp->setStyleSheet(qss);
        file.close();
    }

    int fontId = QFontDatabase::addApplicationFont("MILT_RG.ttf");
    QStringList fontIDs = QFontDatabase::applicationFontFamilies(fontId);
    if (!fontIDs.isEmpty())
    {
        QFont font(fontIDs.first(), 10);
        font.setStyleStrategy(QFont::PreferAntialias);
        a.setFont(font);
    }
    else
    {
        qDebug()<<"Failed to load font.";
    }

    FileCheck w;
    w.show();

    return a.exec();
}
